package com.fuyao.cloud.admin.flow.dto;

import com.fuyao.cloud.admin.api.entity.SysUser;
import com.fuyao.cloud.flowable.vo.ActorInstance;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

@NoArgsConstructor
@Data
public class Handler {
    private String id;
    private String name;
    private String code;
    private String mobile;
    private String deptId;
    private String deptName;


    public Handler(SysUser sysUser) {
        this.id = String.valueOf(sysUser.getUserId());
        this.name = sysUser.getName();
        this.code = sysUser.getUsername();
        this.mobile = sysUser.getPhone();
        this.deptId = String.valueOf(sysUser.getDeptId());
        this.deptName = sysUser.getDeptName();
    }

    public Handler(ActorInstance actorInstance) {
        this.id = String.valueOf(actorInstance.getUserId());
        this.name = actorInstance.getName();
        this.code = actorInstance.getUsername();
        this.deptId = String.valueOf(actorInstance.getDeptId());
        this.deptName = actorInstance.getOuName();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Handler handler = (Handler) o;
        return  Objects.equals(code, handler.code);
    }

    @Override
    public int hashCode() {
        return Objects.hash(code);
    }
}
